using ControlCenter.Model;
using ControlCenter.Model.BizEntities;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ControlCenter.Model.WebApiDto;

namespace ControlCenter.Operation
{
    /// <summary>
    /// 应用包操作接口
    /// </summary>
    public interface IPackageManagementOperation
    {
        // -- 机器人的应用包 ----------------------------------------------------------------------------

        /// <summary>
        /// 更新机器人的包状态，停用/启用
        /// </summary>
        /// <param name="updatePackageStatusDto"></param>
        /// <returns></returns>
        Task<bool> UpdatePackageStatus(UpdatePackageStatusDto updatePackageStatusDto);
        /// <summary>
        /// 获取需要执行的包的信息
        /// </summary>
        /// <param name="robotId"></param>
        /// <returns></returns>
        Task<IEnumerable<WaitExecutionPackageDto>> QueryWaitExectionPackage(Guid robotId);
        /// <summary>
        /// 获取指定的packageInfo
        /// </summary>
        /// <param name="packageId"></param>
        /// <returns></returns>
        Task<RobotPackageInfo> Find(Guid packageId);
        /// <summary>
        /// 根据机器人id获取包列表
        /// </summary>
        /// <param name="robotId"></param>
        /// <returns></returns>
        Task<IEnumerable<RobotPackageInfo>> QueryPackage(Guid robotId);
        /// <summary>
        /// 查询所有机器人的应用包概要信息列表
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<RobotPackageShortInfo>> QueryRobotPackageShortInfo();
        /// <summary>
        /// 查询机器人的应用包列表
        /// </summary>
        /// <param name="robotId"></param>
        /// <returns></returns>
        Task<IEnumerable<SaveRobotPackageInfo>> QuerySaveRobotPackageInfo(Guid robotId);
        /// <summary>
        /// 更新机器人的包数据
        /// </summary>
        /// <param name="saveDto"></param>
        /// <returns></returns>
        Task<bool> UpdateRobotPackageInfo(SaveRobotInfoDto saveDto);
        /// <summary>
        /// 更新机器人应用包的状态
        /// </summary>
        /// <param name="rpId"></param>
        /// <param name="packageStatus"></param>
        /// <param name="oldPackageStatus"></param>
        /// <returns></returns>
        Task UpdateRobotPackagePackageStatus(Guid rpId, int packageStatus, int? oldPackageStatus = null);
        /// <summary>
        /// 删除机器人的应用包
        /// </summary>
        /// <param name="rpId"></param>
        /// <returns></returns>
        Task DeleteRobotPackage(Guid rpId);


        // -- 应用包 ----------------------------------------------------------------------------

        /// <summary>
        /// 判断包是否存在
        /// </summary>
        /// <param name="projectName"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        Task<bool> IsExist(string projectName, string version);
        /// <summary>
        /// 保存包信息到数据库
        /// </summary>
        /// <param name="projectPackageInfo"></param>
        /// <returns></returns>
        Task SavePackageInfo(ProjectPackageInfo projectPackageInfo);
        /// <summary>
        /// 根据条件查询应用包数据，返回分页数据
        /// </summary>
        /// <param name="paramDto"></param>
        /// <returns></returns>
        Task<PagedData<ProjectPackageInfo>> QueryPackageInfo(PackageQueryDto paramDto);
        /// <summary>
        /// 根据包ID查询应用包信息
        /// </summary>
        /// <param name="packageId"></param>
        /// <returns></returns>
        Task<ProjectPackageInfo> FindPackageInfo(Guid packageId);
        /// <summary>
        /// 根据包名称查询应用包信息
        /// </summary>
        /// <param name="packageName"></param>
        /// <returns></returns>
        Task<ProjectPackageInfo> FindPackageInfo(string packageName);
        /// <summary>
        /// 增加一个应用包
        /// </summary>
        /// <param name="packageInfo"></param>
        /// <param name="configItems"></param>
        /// <returns></returns>
        Task<bool> InsertPackageInfo(ProjectPackageInfo packageInfo, List<PackageConfigItem> configItems);
        /// <summary>
        /// 更新应用包信息
        /// </summary>
        /// <param name="packageInfo"></param>
        /// <param name="configItems"></param>
        /// <returns></returns>
        Task<bool> UpdatePackageInfo(ProjectPackageInfo packageInfo, List<PackageConfigItem> configItems);
        /// <summary>
        /// 根据包ID删除应用包
        /// </summary>
        /// <param name="packageId"></param>
        /// <returns></returns>
        Task<Tuple<bool, string>> DeletePackageInfo(Guid packageId);

        //-- 包参数配置 -------------------------------------------------------------------------------------------------------
        /// <summary>
        /// 查询指定应用包的参数配置
        /// </summary>
        /// <param name="packageId">应用包ID</param>
        /// <returns></returns>
        Task<IEnumerable<PackageConfigItem>> QueryPackageConfig(Guid packageId);

        /// <summary>
        /// 更新应用包的参数配置
        /// </summary>
        /// <param name="packageConfigItems"></param>
        /// <returns></returns>
        Task<Tuple<bool, string>> UpdatePackageConfig(List<PackageConfigItem> packageConfigItems);
    }
}
